<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>11-继承关系子类扩展自己方法</title>
	</head>
	<body>
		<script type="text/javascript">
			//超类 MathUtil-类名称
			class MathUtil{
				//构造函数
				constructor(x,y) {
				    this.x = x;
					this.y = y;
				}
				//加法
				sum(){
					console.log(parseFloat(this.x+this.y));
				}
			}
			//子类
			class MergeUtil extends MathUtil{
				//构造函数
				constructor(x,y) {
				    super(x,y);
					this.x = x;
					this.y = y;
				}
				slice(){
					console.log(parseFloat(this.x-this.y));
				}
			}
			
			var util = new MergeUtil(1,8);
			util.sum();
			util.slice();
		</script>
	</body>
</html>
